package gc;
/**
 * 主流java虚拟机里没有选用引用计数算法来管理内存，他很难解决对象间互相循环引用的问题
 * -verbose:gc -XX:+PrintGCDetails
 * @author Ditto
 *
 */
public class ReferenceCountingGC {

	public Object instance = null;
	private static final int _1MB=1024*1024;
	
	private byte[] bigSize = new byte[2*_1MB];
	
	public static void testGC(){
		ReferenceCountingGC objA = new ReferenceCountingGC();
		ReferenceCountingGC objB = new ReferenceCountingGC();
		objA.instance = objB;
		objB.instance = objA;
		
		objA = null;
		objB = null;
		
		System.gc();
	}
	
	public static void main(String[] args) {
		ReferenceCountingGC.testGC();
	}
}
